package lesson3.models;

import java2d.game.FrameAnimation;
import java2d.game.SpriteFrames;
import java2d.game.SpriteGameObject;

/**
 * Author:     Zhao Yan
 * DateTime:   2023/4/18 19:51
 */
public class Explosion extends SpriteGameObject implements FrameAnimation.CompletedEvent {

    public final FrameAnimation animation = new FrameAnimation();

    public Explosion() {
        super("assets/animations/explosion/explosion-1.png");

        animation.frames = SpriteFrames.load("assets/animations/explosion/explosion.ani");
        animation.loop = false;
        animation.completed = this;

        addComponent(animation);
    }

    @Override
    protected void onActivated() {
        animation.play(0.1f);
    }

    @Override
    public void completed() {
        destroy();
    }
}
